home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / scripts / plot / subwindow.m < prev    next >
Text File  |  1996-11-15  |  2KB  |  80 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## usage: subwindow (xn, yn)
  21. ##
  22. ## NOTE: this will work only with gnuplot installed with
  23. ##       multiplot patch
  24. ##
  25. ## Sets subwindow position in multiplot mode for next plot. The
  26. ## multiplot mode has to be previously initialized using multiplot()
  27. ## command, else this command just becomes an aliad to multiplot()
  28.  
  29. ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU>
  30. ## Created: 3 July 95
  31. ## Adapted-By: jwe
  32.  
  33. function subwindow (xn, yn)
  34.  
  35.   if (! gnuplot_has_multiplot)
  36.     error ("subwindow: gnuplot does not appear to support this feature");
  37.   endif
  38.  
  39.   ## global variables to keep track of multiplot options
  40.  
  41.   global multiplot_mode
  42.   global multiplot_xsize multiplot_ysize
  43.   global multiplot_xn multiplot_yn
  44.  
  45.   ## check calling argument count
  46.  
  47.   if (nargin != 2)
  48.     usage ("subwindow (xn, yn)");
  49.   endif
  50.  
  51.   ## check for scalar inputs
  52.  
  53.   if (! (is_scalar (xn) && is_scalar (yn)))
  54.     error ("subwindow: xn and yn have to be scalars");
  55.   endif
  56.  
  57.   xn = round (xn);
  58.   yn = round (yn);
  59.  
  60.   ## switch to multiplot mode if not already in, and use the args as the
  61.   ## args to multiplot()
  62.  
  63.   if (multiplot_mode != 1)
  64.     multiplot (xn, yn);
  65.     return;
  66.   endif
  67.  
  68.   ## get the sub plot location
  69.  
  70.   if (xn < 1 || xn > multiplot_xn || yn < 1 || yn > multiplot_yn)
  71.     error ("subwindow: incorrect xn and yn");
  72.   endif
  73.  
  74.   xo = (xn - 1.0)*multiplot_xsize;
  75.   yo = (multiplot_yn - yn)*multiplot_ysize;
  76.  
  77.   eval (sprintf ("gset origin %g, %g", xo, yo));
  78.  
  79. endfunction
  80.